<?php


namespace app\crontab\controller\once;


use custom\Mongo;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Exception;

/**
 * 合并Mongo商圈小区表
 * Class MergeXiaoQuMongoDB
 * @package app\crontab\controller
 */
class MergeXiaoQuMongoDB extends Command {

    static $dbname = 'test';
    static $set1 = 'ajk_xiaoqu_url';
    static $set2 = 'ajk_xiaoqu_url_2020_1_7';

    protected function configure() {
        $this->setName('MergeXiaoQuMongoDB');
    }

    protected function execute(Input $input, Output $output) {
        $this->initial();
    }

    public function initial() {
        echo "runing\n";
        try {
            $mongo = Mongo::getInstance();
            $where = [];
            $option = [];
            $data = $mongo->select(self::$set2, $where, $option);
            $count = $mongo->getCount(self::$set2, $where);
            $suc = $mongo->addData($data, self::$set1);
            echo "total->$count,suc->$suc\n";
            echo "end\n";
        } catch (Exception $exception) {
            echo $exception->getMessage();
        }
    }

}